﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Data.SqlClient;
using ZLDC.Common.BaseUser;



namespace ZLDC.Common
{
    public class C_GetSimilarPercent
    {
        public C_GetSimilarPercent()
        {
        }
        /*
         * 编写人:mico
         * 日期:  2009-04-01
         * 功能: 获取最大相似百分率
         * sTable:要匹配查找的表名
         * sField:要匹配查找的字段名


         * sMatching:要与其相似匹配的字串
        */
        public static string GetPercent(string sTable, string sField, string sMatching, string IDField, string IDvalue, string sqlCondition)
        {
            string sPercent = "";
            string sql;

            sql = " select max(dbo.SearchConform( " + sField + " ,'" + CheckString.CheckStr(sMatching) + "')) as MaxPercent from " + sTable + " where " + IDField + "<> '" + IDvalue + "' " + sqlCondition + " ";


            SqlDataReader dr;
            DataBase db = new DataBase();
            dr = db.SelectRecord(sql);
            if (dr.Read())
            {
                sPercent = dr["MaxPercent"].ToString();
                dr.Close();
                db.ConnectClose();
                return sPercent;
            }
            else
            {
                dr.Close();
                db.ConnectClose();
                return "";
            }
        }



    }
}